.class public Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;
.super Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaController;
.source "OrmmaNetworkController.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController$1;
    }
.end annotation


# static fields
.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "OrmmaNetworkController"


# instance fields
.field private mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

.field private mConnectivityManager:Landroid/net/ConnectivityManager;

.field private mFilter:Landroid/content/IntentFilter;

.field private mNetworkListenerCount:I


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 27
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method public constructor <init>(Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaView;Landroid/content/Context;)V
    .locals 1
    .parameter "adView"
    .parameter "context"

    .prologue
    .line 61
    invoke-direct {p0, p1, p2}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaController;-><init>(Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaView;Landroid/content/Context;)V

    .line 62
    const-string v0, "connectivity"

    invoke-virtual {p2, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    iput-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mConnectivityManager:Landroid/net/ConnectivityManager;

    .line 63
    return-void
.end method


# virtual methods
.method public getNetwork()Ljava/lang/String;
    .locals 8
    .annotation runtime Landroid/webkit/JavascriptInterface;
    .end annotation

    .prologue
    const/4 v6, 0x1

    .line 72
    iget-object v3, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mConnectivityManager:Landroid/net/ConnectivityManager;

    invoke-virtual {v3}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v1

    .line 73
    .local v1, ni:Landroid/net/NetworkInfo;
    const-string v0, "unknown"

    .line 74
    .local v0, networkType:Ljava/lang/String;
    if-nez v1, :cond_1

    .line 75
    const-string v0, "offline"

    .line 93
    :cond_0
    :goto_0
    sget-object v3, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v4, "OrmmaNetworkController"

    const-string v5, "getNetwork: {0}"

    new-array v6, v6, [Ljava/lang/Object;

    const/4 v7, 0x0

    aput-object v0, v6, v7

    invoke-virtual {v3, v4, v5, v6}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 94
    return-object v0

    .line 77
    :cond_1
    sget-object v3, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController$1;->$SwitchMap$android$net$NetworkInfo$State:[I

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->getState()Landroid/net/NetworkInfo$State;

    move-result-object v4

    invoke-virtual {v4}, Landroid/net/NetworkInfo$State;->ordinal()I

    move-result v4

    aget v3, v3, v4

    packed-switch v3, :pswitch_data_0

    .line 85
    invoke-virtual {v1}, Landroid/net/NetworkInfo;->getType()I

    move-result v2

    .line 86
    .local v2, type:I
    if-nez v2, :cond_2

    .line 87
    const-string v0, "cell"

    goto :goto_0

    .line 79
    .end local v2           #type:I
    :pswitch_0
    const-string v0, "unknown"

    .line 80
    goto :goto_0

    .line 82
    :pswitch_1
    const-string v0, "offline"

    .line 83
    goto :goto_0

    .line 88
    .restart local v2       #type:I
    :cond_2
    if-ne v2, v6, :cond_0

    .line 89
    const-string v0, "wifi"

    goto :goto_0

    .line 77
    nop

    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_0
        :pswitch_1
    .end packed-switch
.end method

.method public onConnectionChanged()V
    .locals 4

    .prologue
    .line 126
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "window.ormmaview.fireChangeEvent({ network: \'"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {p0}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->getNetwork()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "\'});"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 127
    .local v0, script:Ljava/lang/String;
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "OrmmaNetworkController"

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v1, v2, v0, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 128
    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mOrmmaView:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaView;

    invoke-virtual {v1, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaView;->injectJavaScript(Ljava/lang/String;)V

    .line 129
    return-void
.end method

.method public startNetworkListener()V
    .locals 3

    .prologue
    .line 101
    iget v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    if-nez v0, :cond_0

    .line 102
    new-instance v0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    invoke-direct {v0, p0}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;-><init>(Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;)V

    iput-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    .line 103
    new-instance v0, Landroid/content/IntentFilter;

    invoke-direct {v0}, Landroid/content/IntentFilter;-><init>()V

    iput-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mFilter:Landroid/content/IntentFilter;

    .line 104
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mFilter:Landroid/content/IntentFilter;

    const-string v1, "android.net.conn.CONNECTIVITY_CHANGE"

    invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 106
    :cond_0
    iget v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    .line 107
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mContext:Landroid/content/Context;

    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    iget-object v2, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mFilter:Landroid/content/IntentFilter;

    invoke-virtual {v0, v1, v2}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 108
    return-void
.end method

.method public stopAllListeners()V
    .locals 3

    .prologue
    .line 133
    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    if-eqz v1, :cond_0

    .line 134
    const/4 v1, 0x0

    iput v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    .line 136
    :try_start_0
    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mContext:Landroid/content/Context;

    iget-object v2, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    invoke-virtual {v1, v2}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 142
    :cond_0
    :goto_0
    return-void

    .line 138
    :catch_0
    move-exception v0

    .line 139
    .local v0, e:Ljava/lang/Exception;
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "OrmmaNetworkController"

    invoke-virtual {v1, v2, v0}, Lcom/burstly/lib/util/LoggerExt;->logThrowable(Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method public stopNetworkListener()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 114
    iget v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    add-int/lit8 v0, v0, -0x1

    iput v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    .line 115
    iget v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mNetworkListenerCount:I

    if-nez v0, :cond_0

    .line 116
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mContext:Landroid/content/Context;

    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    invoke-virtual {v0, v1}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 117
    iput-object v2, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mBroadCastReceiver:Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/util/OrmmaNetworkBroadcastReceiver;

    .line 118
    iput-object v2, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaNetworkController;->mFilter:Landroid/content/IntentFilter;

    .line 120
    :cond_0
    return-void
.end method
